In [1]:
%matplotlib inline
import numpy
import matplotlib.pyplot as plt
import matplotlib.colors as mcolor
import watershed
In [2]:
pb = watershed.load_example('powell_butte') * 1000
fig, ax = plt.subplots(figsize=(6,6))
img = ax.imshow(pb, interpolation='none', cmap=plt.cm.Blues_r, vmax=120)
fig.colorbar(img)
Out[2]:
In [3]:
flow_dir = watershed.flow_direction_d8(pb)`
bounds = sorted(watershed.algo.DIR_MAP.values())
cmap = plt.cm.Set1_r
norm = mcolor.BoundaryNorm(bounds, cmap.N)
fig, ax = plt.subplots(figsize=(6,6))
img = ax.imshow(flow_dir, interpolation='none', cmap=cmap, norm=norm)
fig.colorbar(img)
Out[3]: